<?php


namespace app\handler;

class Aes
{
    private $_iv = '!#@zxrrty0789^&*^__+';
    private $_secret = 'zzb%^@23~213~09@#$_af';

    public function __construct(){
        $this->_iv = substr($this->_iv.'0000000000000000', 0,16);
        $this->_secret = hash('md5',$this->_secret,true);
    }

    public function decode($secretData){
        return openssl_decrypt(urldecode($secretData),'aes-128-cbc',$this->_secret,false,$this->_iv);
    }

    public function encode($data){
        return urlencode(openssl_encrypt($data,'aes-128-cbc',$this->_secret,false,$this->_iv));
    }
}